package ar.com.cooker.services.util;

import org.springframework.context.support.FileSystemXmlApplicationContext;


public class ManagerBean {

	private static ManagerBean MANAGER_BEAN;

	private final String[] SPRING_CONFIG_FILES = new String[] { "classpath*:Application-Context.xml" };

	private ManagerBean() {
	}

	/**
	 * Obtiene la instancia de un objeto manager.
	 * 
	 * @return manager inicializado.
	 */
	public synchronized static ManagerBean getManager() {

		if (MANAGER_BEAN == null) {
			MANAGER_BEAN = new ManagerBean();
		}
		return MANAGER_BEAN;
	}

	/**
	 * Permite obtener un bean por su nombre al contexto.
	 * 
	 * @param nameBean
	 * @return bean requerido.
	 */
	public Object getBean(String nameBean) {
		FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext(
				SPRING_CONFIG_FILES);
		return appContext.getBean(nameBean);
	}
}
